package laborhazi;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MouseControl implements MouseListener{
	private Field field;
	private Game game;
	private Viewer viewer;
	public MouseControl(Viewer v, Field f, Game g) {
		viewer = v;
		game = g;
		field = f;
	}
	public void mouseClicked(MouseEvent e) {
		int[] position;
		position = new int[2];
		position[0] = e.getX();
		position[1] = e.getY();
		position = viewer.viewToField(position);
		System.out.println(position[0] + " CLICK CLICK " + position[1]);
		if (field.check(position) instanceof Lemming && game.toolbar != null) {
			game.toolbar.give((Lemming)(field.check(position)));
		}
		if (field.check(position) instanceof SetLemming && game.toolbar != null) {
			game.toolbar.give((SetLemming)(field.check(position)));
		}
		
	}
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}	
}
